package a4;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.jgrapht.graph.DefaultEdge;
import org.jgrapht.graph.DefaultWeightedEdge;
import org.jgrapht.graph.SimpleDirectedWeightedGraph;
import org.jgrapht.graph.SimpleWeightedGraph;
import org.jgrapht.graph.WeightedMultigraph;

public class GKAA4 {
    public static void main(String ... args) throws FileNotFoundException, IOException {
		BufferedReader br = new BufferedReader(new FileReader("src\\Graph11.graph"));
        String str = null;
        String whatgraph = br.readLine();
        WeightedMultigraph<String, DefaultWeightedEdge> sg = new WeightedMultigraph<>(DefaultWeightedEdge.class);
        
        while ((str = br.readLine()) != null) {
                String[] parts = str.split(",");
				sg.addVertex(parts[0]);
                sg.addVertex(parts[1]);
                DefaultWeightedEdge edge = sg.addEdge(parts[0], parts[1]);
                sg.setEdgeWeight(edge, Double.parseDouble(parts[2]));
        }
		//Hierholzer h = new Hierholzer();
		//h.GetEulerCircle(sg);
		SymTSP sym = new SymTSP();
		System.out.println(sym.SolveTSP(sg));
    }
}
